package com.codefish;

public class exercises0604 {
    public static void main(String[] args) {
        /*
        题目要求：
        1.定义一个方法，用来判断两个数字是否相同
        2.定义一个方法，用来求出1-100之间所有数字的和值
        3.定义一个方法，用来打印指定次数的HelloWorld.
         */

        //1
        System.out.println(isSame1(10,20) ); //false
        System.out.println(isSame2(20,20) ); //true
        System.out.println(isSame3(20,30) ); //false
        System.out.println(isSame4(30,30) ); //true

        System.out.println("=======================================");

        //2
        System.out.println("结果是："+ getSum()); //5050

        //3
        printCount(10);

    }

    //1
    public static boolean isSame1(int a, int b) {
        boolean same;
        if (a == b) {
            same = true;
        } else {
            same = false;
        }

        return same;



    }

    public static boolean isSame2(int a, int b) {
        boolean same = a == b ? true : false;
        return same;
    }

    public static boolean isSame3(int a, int b) {
        boolean same = a == b;
        return same;
    }

    public static boolean isSame4(int a, int b) {
        return a == b;
    }

    //2
    public static int getSum(){
        int sum = 0;
        for (int i = 1; i <= 100;i++){
            sum += i;
        }
        return sum;
    }

    //3
    public static void printCount(int num){
        for (int i = 1;i <= num;i++){
            System.out.println("HelloWord!" + i);
        }
    }

}